package com.miku.blog.utils;

import com.miku.blog.domain.pojo.SystemConstance;

/**
 * @author shkstart
 * @create ${}YEAR-06-16 4:14
 */
public class PathUtils {


    public static String getPathPrefix(String path) {

        String prefix;
        if (path.lastIndexOf("/") != 0) {

            if (path.startsWith(SystemConstance.ADMIN_URI)) {
                int index = path.indexOf("/", 1);
                String substring = path.substring(index);
                String pathPrefix = getPathPrefix(substring);
                prefix = SystemConstance.ADMIN_URI + pathPrefix;
            } else {
                prefix = path.substring(0, path.indexOf("/", 1));
            }
        } else {
            prefix = path;
        }
        return prefix;

    }


}
